var opinionPrice;

/**
 * 设置结果接收对象
 * @param _opinionPrice
 */
function setModel(_opinionPrice) {
    if (_opinionPrice == undefined || !(_opinionPrice instanceof com.jf.crawl.model.OpinionPrice)) {
        throw new java.lang.Exception("opinionPrice 对象为空");
    }
    log.info("opinionPrice {}", _opinionPrice)
    opinionPrice = _opinionPrice;
}

function crawler() {
    //点融网
    //    新手团--10
    //    季季翻--8
    //    节节发--4.5
    //    小融包--浮动
    //    经典团--6
    //    月月盈--7.2
    var result = Get("https://www.dianrong.com/feapi/plans");
    var jsonObject = JSON.parseObject(result);
    if (jsonObject.containsKey("content")) {
        var jsonArray = jsonObject.getJSONObject("content").getJSONArray("list");
        for (var i = 0; i < jsonArray.size(); i++) {
            jsonObject = jsonArray.getJSONObject(i);
            var name = jsonObject.getString("name");
            var intRateDisplay = jsonObject.getString("intRateDisplay");
            if (intRateDisplay.contains("-")) {
                intRateDisplay = intRateDisplay.split("-")[0];
            }
            if ("季季翻".equals(name)) {
                opinionPrice.setOneYear(commonUtil.string2Decimal(intRateDisplay));
            } else if ("节节发".equals(name)) {
                opinionPrice.setOneMonth(commonUtil.string2Decimal(intRateDisplay));
            } else if ("经典团".equals(name)) {
                opinionPrice.setThreeMonth(commonUtil.string2Decimal(intRateDisplay));
            } else if ("月月盈".equals(name)) {
                opinionPrice.setNineMonth(commonUtil.string2Decimal(intRateDisplay));
            }
        }
    }
    return true;
}
